package com.reyco1.medusa.util
{
	public class MathUtil
	{
		public static function random(maxInt:Number, minInt:Number = 0):Number
		{
			maxInt++;
			return Math.floor(minInt + (Math.random() * (maxInt - minInt)));
		}
		
		public static  function percentage(partial:Number, total:Number):Number
		{
			return partial / total;
		}
		
		public static  function getSign(number:Number):Number
		{
			return number / Math.abs(number);
		}
		
		public static function normalize(value:Number, minimum:Number, maximum:Number):Number
		{
			return (value - minimum) / (maximum - minimum);
		}
		
		public static function interpolate(normValue:Number, minimum:Number, maximum:Number):Number
		{
			return minimum + (maximum - minimum) * normValue;
		}
		
		public static function map(value:Number, min1:Number, max1:Number, min2:Number, max2:Number):Number
		{
			return interpolate( normalize(value, min1, max1), min2, max2 );
		}
		
		public static function fibonacci(index:int):int
		{
			if (index < 2) return 1;
			else return MathUtil.fibonacci(index - 1) + MathUtil.fibonacci(index - 2);
		}
		
		public static function toRadians(degrees:Number):Number
		{
			return degrees * Math.PI / 180;
		}
		
		public static function toDegrees(radians:Number):Number
		{
			return radians * 180 / Math.PI;
		}
	}
}